package org.example.springioc;

import lombok.val;
import org.example.springioc.StudentController.StudentController;
import org.example.springioc.dano.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class SpringIocApplication {

    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(SpringIocApplication.class, args);

        //适合该对象类型只有一个
         /*HelloController bean1 = context.getBean(HelloController.class);
         bean1.print();

         HelloController bean2 = (HelloController) context.getBean("helloController");
         bean2.print();

         HelloController bean3 = context.getBean("helloController", HelloController.class);
         bean3.print();
    }*/

        /*UsreService bean = context.getBean(UsreService.class);  //这几个注解都是将对象交给Spring，Spring帮我们创建一个对象，
        //bean.print();                                           //默认类的名称为类名小驼峰的形式, 也可以通过注解指定名称
        System.out.println(bean);

        UserRepository bean2  =context.getBean(UserRepository.class);
        bean2.print();

        UserCompent bean3  =context.getBean(UserCompent.class);
        bean3.print();

        UserConfig bean4  =context.getBean(UserConfig.class);
        bean4.print();*/


        /*Test test = (Test) context.getBean("test");
        test.tests();
*/

       StudentController bean = context.getBean(StudentController.class);
       bean.s1();
    }
}
